#include <iostream>
#include <thread>
#include <vector>
#include <unistd.h>
#include "HttpCurl.h"

using namespace std;

class CHttpTest : public CHttpCurl
{
    public:
        CHttpTest(){}
        ~CHttpTest(){}
        void Response(std::string& response)
        {   
            std::cout<<response<<std::endl;
        }   
};

void testGetThread(int i)
{
	printf("num:%d\n",i);
	//std::string geturl = "https://www.googleapis.com/androidpublisher/v2/applications/packageName/purchases/products/productId/tokens/token";
	std::string geturl = "https://fanyi.baidu.com/?aldtype=16047#auto/zh";
	CHttpTest ht;
	ht.Get(geturl);
	//CHttpCurl::CurlGlobalCleanUp();
}

void testPostThread(int i)
{
	printf("num:%d\n", i);
	std::string posturl = "https://accounts.google.com/o/oauth2/token";
	std::string postfileds = "grant_type=refresh_token&client_id=client_id&client_secret=client_secret&refresh_token=refresh_token";
	//CHttpCurl::CurlGlobalInit();
	CHttpTest ht;
	ht.Post(posturl, postfileds);
}

int main()
{
	static const int numthread = 100;
	thread mythread[numthread];
	for (int i = 0; i < numthread;i++)
	{
		mythread[i] = thread(testGetThread, i);
	}

	for (int i = 0; i < numthread; i++)
	{
		mythread[i].join();
		cout << i << endl;
	}

	//pause();
    return 0;
}
